package com.longli.tank.chainofresponsibility;

import com.longli.tank.AbstractGameObject;
import com.longli.tank.Bullet;
import com.longli.tank.Wall;

public class BulletWallCollider implements Collider {
    @Override
    public void collide(AbstractGameObject go1, AbstractGameObject go2) {
        if(go1 instanceof Bullet && go2 instanceof Wall){
//            System.out.println(go1);
//            System.out.println(go2);
            Bullet b=(Bullet) go1;
            Wall w=(Wall) go2;
            if(b.isLive()){
                if(b.getRect().intersects(w.getRect())){
                    b.die();
                }
            }
        }else if(go2 instanceof Bullet && go1 instanceof Wall){
            collide(go2,go1);
        }
    }
}
